package com.hzhr.iot.toll.controller;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.Author;
import com.hzhr.iot.core.dto.ResponseExceptionDto;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.toll.controller.base.BaseController;
import com.hzhr.iot.toll.model.gasUser.GasUserDeleteModel;
import com.hzhr.iot.toll.model.gasUser.GasUserGetModel;
import com.hzhr.iot.toll.model.gasUser.GasUserPostModel;
import com.hzhr.iot.toll.model.gasUser.GasUserPutModel;
import com.hzhr.iot.toll.model.userGasUser.UserGasUserDeleteModel;
import com.hzhr.iot.toll.model.userGasUser.UserGasUserGetModel;
import com.hzhr.iot.toll.model.userGasUser.UserGasUserPostModel;
import com.hzhr.iot.toll.service.GasUserService;
import com.hzhr.iot.toll.service.UserGasUserService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "UserGasUser", description = "用户与燃气用户的关系")
@RestController
@RequestMapping(value = "")
public class UserGasUserController extends BaseController {
    @Autowired
    UserGasUserService userGasUserService;

    //region /user-gas-users POST
    //region swagger响应码 : post
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
            @ApiResponse(code = 403, message = "----异常代码 : 201  \n----异常类型 : 业务流程异常  \n----异常业务 : 验证用户与燃气用户的关系的存在性  \n----异常说明 : 用户与燃气用户的关系已存在  \n\n", response = ResponseExceptionDto.class),
    })
    //endregion
    //region swagger说明 : post
    @ApiOperation(value="新增用户与燃气用户的关系", notes="新增用户与燃气用户的关系  \n步骤 :  \n1. 验证用户与燃气用户的关系的存在性 : (√)  \n根据以下筛选条件查询UserGasUserEntity的数量，如果数量 > 0，则抛出异常201：  \n          (1) userGasUserEntity.userId = body.userId;  \n          (2) userGasUserEntity.gasUserId = body.gasUserId;  \n2. 新增用户与燃气用户的关系 : (√)  \n根据body创建UserGasUserEntity对象userGasUser_1;  \n3. 返回信息 : (√)  \n查询创建的userGasUser_1，并根据创建的userGasUser_1、新增数量和条件参数生成结果对象并返回；  \n",produces = "application/json")
    //endregion
    //region swagger参数 : post
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

    })
    //endregion
    //region 请求 : post
    @RequestMapping(value = "/user-gas-users", method = RequestMethod.POST)
    //endregion
    @Author
    public ResponseEntity<UserGasUserGetModel> post(@RequestParam @ApiIgnore Map<String, Object> query,
                                                @RequestBody UserGasUserPostModel body) throws ServiceException {
        UserGasUserGetModel responseBody = userGasUserService.post(initHeader(), query, body);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
    }
    //endregion

    //region /user-gas-users DELETE
    //region swagger响应码 : delete
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : delete
    @ApiOperation(value="删除用户与燃气用户的关系", notes="删除用户与燃气用户的关系  \n步骤 :  \n1. 删除用户与燃气用户的关系 : (√)  \n根据条件参数删除UserGasUserEntity;  \n2. 返回信息 : (√)  \n根据删除数量生成结果对象并返回;  \n",produces = "application/json")
    //endregion
    //region swagger参数 : delete
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "equal_userId", value = "筛选条件 : where UserGasUserModel.userId = #{equal_userId}",required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_gasUserId", value = "筛选条件 : where UserGasUserModel.gasUserId = #{equal_gasUserId}",required = true, dataType = "int", paramType = "query"),
    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_equal_userId", value = "筛选条件 : where UserGasUserModel.userId = #{_equal_userId}",required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_gasUserId", value = "筛选条件 : where UserGasUserModel.gasUserId = #{_equal_gasUserId}",required = true, dataType = "int", paramType = "query"),
    })
    //endregion
    //region 请求 : delete
    @RequestMapping(value = "/user-gas-users", method = RequestMethod.DELETE)
    //endregion
    @Author
    public ResponseEntity<UserGasUserDeleteModel> delete(@RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        UserGasUserDeleteModel responseBody = userGasUserService.delete(initHeader(), query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
    }
    //endregion

    //region /user-gas-users GET
    //region swagger响应码 : get
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : get
    @ApiOperation(value="查询用户与燃气用户的关系", notes="查询用户与燃气用户的关系  \n步骤 :  \n1. 查询燃气用户 : (√)  \n根据条件参数查询UserGasUserEntityExt对象集合userGasUser_1及总数；  \n2. 返回信息 : (√)  \n根据查询到的userGasUser_1、总数和条件参数生成结果对象并返回；  \n",produces = "application/json")
    //endregion
    //region swagger参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where UserGasUserModel.id = #{equal_id}",required = true, dataType = "int", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where UserGasUserModel.id = #{_equal_id}",required = true, dataType = "int", paramType = "query"),

    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/user-gas-users", method = RequestMethod.GET)
    //endregion
    @Author
    public ResponseEntity<UserGasUserGetModel> get(@RequestParam @ApiIgnore Map<String, Object> query) throws Exception {
        UserGasUserGetModel responseBody = userGasUserService.get(initHeader(), query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
    }
    //endregion
}















































































































































































































































































